﻿using System;
using System.Collections.Generic;
using Autodesk.Revit.DB;
using YJKArch.Utils;

namespace YJKAreaCutter.Utils
{
	public class UnitTestUtils
	{
		public static void PointCheckPosition(List<XYZ> arPoint, Autodesk.Revit.DB.Document doc, Autodesk.Revit.DB.View view)
		{
			foreach (XYZ point in arPoint)
			{
				UnitTestUtils.CreatePointByDetailCurve(point, doc, view);
			}
		}

		public static void CurveCheckPosition(List<Curve> arCurve, Autodesk.Revit.DB.Document doc)
		{
			foreach (Curve curve in arCurve)
			{
				UnitTestUtils.CreateCurveByDetailCurve(curve, doc);
			}
		}

		public static void CurveCheckPosition(CurveArray curveArr, Autodesk.Revit.DB.Document doc, Autodesk.Revit.DB.View view)
		{
			doc.Create.NewDetailCurveArray(view, curveArr);
		}

		public static void CurveCheckPosition(CurveLoop loop, Autodesk.Revit.DB.Document doc)
		{
			foreach (Curve curve in loop)
			{
				UnitTestUtils.CreateCurveByDetailCurve(curve, doc);
			}
		}

		public static void CurveCheckPosition(CurveLoop loop, Autodesk.Revit.DB.Document doc, Autodesk.Revit.DB.View view)
		{
			foreach (Curve curve in loop)
			{
				UnitTestUtils.CreateCurveByDetailCurve(curve, doc, view);
			}
		}

		private static void CreatePointByDetailCurve(XYZ point, Autodesk.Revit.DB.Document doc, Autodesk.Revit.DB.View view)
		{
			double num = Common.MMtoIntch(300.0);
			XYZ xyz = point - XYZ.BasisX.Multiply(num);
			XYZ xyz2 = point + XYZ.BasisX.Multiply(num);
			XYZ xyz3 = point + XYZ.BasisY.Multiply(num);
			XYZ xyz4 = point - XYZ.BasisY.Multiply(num);
			Line line = Line.CreateBound(xyz, xyz2);
			Line line2 = Line.CreateBound(xyz3, xyz4);
			doc.Create.NewDetailCurve(view, line);
			doc.Create.NewDetailCurve(view, line2);
		}

		private static void CreateCurveByDetailCurve(Curve curve, Autodesk.Revit.DB.Document doc)
		{
			doc.Create.NewDetailCurve(doc.ActiveView, curve);
		}

		private static void CreateCurveByDetailCurve(Curve curve, Autodesk.Revit.DB.Document doc, Autodesk.Revit.DB.View view)
		{
			doc.Create.NewDetailCurve(view, curve);
		}
	}
}
